package Test;

import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * @author 陈Ser
 * @ClassName tem
 * @description: TODO
 * @Date 2021/9/15 16:04
 * @Version 1.0
 */
public class tem {
    public static void main(String[] args) {
        User user = new User("john@gmail.com", "1234");

        List<String> emails = Optional.ofNullable(user)
                .stream()
                .filter(u -> u.getEmail() != null && u.getEmail().contains("@"))
                .map(u -> u.getEmail())
                .collect(Collectors.toList());
        System.out.println(emails);


    }
}
